//======================================================================
/// COPYRIGHT MorningCoreTech CO.,LTD
/// @file        PUCCH_DmrsSeq_Gen_fix.cpp
/// @brief       This function performs PUCCH DmrsSeq Gen Proc
/// @author      cuiyuping
/// @param [IN]	     SimParam		               Input  Parameter .
/// @param [IN]	     PUCCH_DMRS_Ip		           DMRS Seq
/// @param [OUT]	 PUCCH_ZC_Data		           Data Seq     

/// @par History
/// -
///       Date|       Author|        Version|        DESCRIPTION
/// ----------|-------------|---------------|-------------------
/// 2022-10-20|   cuiyuping |          0.0.1|            created
//======================================================================
#include "../../../CommLib_FxpC/lib_arith_N.h"
#include "../../../CommLib_FltC/GlobalVarDef.h"
#include "../common/head/NR_UL_macro.h"
#include "ue_tx_pucch_dmrs_gen_fix.h"


void PUCCH_DMRS_Gen_fix
(
	IN stULParamTable *SimParam,
	IN    cmplx_frN *PUCCH_DMRS_Ip[PUCCH_DMRS_MAX_NUM],
	OUT   cmplx_frN *PUCCH_DMRS_Op[PUCCH_DMRS_MAX_NUM]
)
{
    /*variables definition*/
    int16       *P_OVSF_Code;
    cmplx_frN   OVSF_Code;    
	int8 l,DmrsSymSecondHop;
	uint16 k;
	set_rnd_mode_floor();

    /*Function body*/

   if (PUCCH_FORMAT_0 == SimParam->PUCCH_Format)
	{

        if (0 == SimParam->intra_slot_hopping)
        {      		
				
            P_OVSF_Code = NocSF_F0_Fix[SimParam->DmrsSymNum - 1][SimParam->F1_OCC_Index];
            for (l=0; l<SimParam->DmrsSymNum; l++)
            {
                /*get OVSF code*/
                OVSF_Code.re = (fractN)*P_OVSF_Code++;
                OVSF_Code.im = (fractN)*P_OVSF_Code++;
                for (k=0; k<SC_PER_RB; k++)
                {
					PUCCH_DMRS_Op[l][k] = Cmlt_frN(PUCCH_DMRS_Ip[l][k],OVSF_Code); //w(m)*r(i)						
                }
                	
            }
        }
		else
		{
            DmrsSymSecondHop = SimParam->DmrsSymNum - SimParam->DmrsSymFirstHop;		

            P_OVSF_Code = NocSF_F0_Fix[SimParam->DmrsSymFirstHop - 1][SimParam->F1_OCC_Index];//guobaojuan,20180514

			//first hopping
            for (l=0; l<SimParam->DmrsSymFirstHop; l++)
            {
                /*get OVSF code*/
                OVSF_Code.re = *P_OVSF_Code++;
                OVSF_Code.im = *P_OVSF_Code++;
                for (k=0; k<SC_PER_RB; k++)
                {
					PUCCH_DMRS_Op[l][k]=Cmlt_frN(PUCCH_DMRS_Ip[l][k],OVSF_Code); //w(m)*r(i)
                     	
                }                
            }

			//secend hopping
			P_OVSF_Code = NocSF_F0_Fix[DmrsSymSecondHop - 1][SimParam->F1_OCC_Index];//guobaojuan,20180514

            for (l=SimParam->DmrsSymFirstHop; l<SimParam->DmrsSymNum; l++)
            {
                /*get OVSF code*/
                OVSF_Code.re = *P_OVSF_Code++;
                OVSF_Code.im = *P_OVSF_Code++;
                for (k=0; k<SC_PER_RB; k++)
                {
					PUCCH_DMRS_Op[l][k]=Cmlt_frN(PUCCH_DMRS_Ip[l][k],OVSF_Code); //w(m)*r(i) 					  
                }          

			}
		}
	   
	}
	else // (PUCCH_FORMAT_1 == SimParam->PUCCH_Format)
	{ 		
        for (l=0; l<SimParam->DmrsSymNum; l++)
        {
            for (k=0; k<SimParam->PUCCH_RB_Num*SC_PER_RB; k++)
            {
				PUCCH_DMRS_Op[l][k] = PUCCH_DMRS_Ip[l][k];
            }
        }
      
	}

}




